package com.spsoft.system.mapper;

import com.spsoft.system.entity.SysFunlist;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.spsoft.system.model.bo.RoleAsMenuCodeBo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 菜单 Mapper 接口
 * </p>
 *
 * @author dlchen
 * @since 2023-11-09
 */
public interface SysFunlistMapper extends BaseMapper<SysFunlist> {


    @Select("SELECT F.MENUID " +
            " FROM  SYS_ROLEFUN S LEFT JOIN  SYS_FUNLIST F   ON S.FUNID = F.FUNID" +
            "        WHERE S.ROLEID = #{roleId}")
    List<String> selectMenuIdByRoleId(@Param("roleId") String roleId);

    @Select("SELECT S.ROLEID roleId ,F.MENUID menuCode" +
            " FROM  SYS_ROLEFUN S LEFT JOIN  SYS_FUNLIST F   ON S.FUNID = F.FUNID" )
    List<RoleAsMenuCodeBo> selectAllMenuIdByRoleId();

    @Select("SELECT C.FUNID,C.FUNNAME,C.PREFUN,C.URL,C.FUNTYPE,C.MENUID,C.INDEXNUM " +
            " FROM  SYS_ROLEFUN S LEFT JOIN  SYS_FUNLIST C   ON S.FUNID = C.FUNID" +
            "   WHERE S.ROLEID = #{roleId}" +
            " AND SUBSTR(C.MENUID,1,4) = 'VMS_' ORDER BY C.PREFUN, C.INDEXNUM ASC")
    List<SysFunlist> selectByRoleId(@Param("roleId") String roleId);
}
